<%@ page language="java" contentType="text/html; charset=utf-8" import="java.util.List,com.hdl.entity.MallCart,com.hdl.entity.CartItem,com.hdl.entity.MallProduct"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>确认收货地址</title>
<link href="assets/css/css/myCart.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" href="assets/plugins/growl-notification/colored-theme.min.css">
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/plugins/growl-notification/growl-notification.min.js"></script>
<script src="assets/js/sys.js"></script>
<style>
	.img{
		width:60px;
		height:60px;
	}
</style>
</head>

<body>
<div id="header" style="height: 80px"><img src="assets/img/images/logo.png" alt="logo" style="width: 225px;height: 80px" /></div>
<div id="nav" >您的位置：<a href="/hdl">首页</a> > <a >收货地址</a></div>
<div id="navlist">
  <ul>
    <li class="navlist_red_left"></li> 
    <li class="navlist_gray">1. 查看购物车</li> 
    <li class="navlist_gray_arrow"></li>
    <li class="navlist_red">2. 确认收货地址</li> 
    <li class="navlist_red_arrow"></li> 
     <li class="navlist_gray">3. 付款到支付宝</li> 
    <li class="navlist_gray_arrow"></li>   
     <li class="navlist_gray">4. 确认收货</li> 
    <li class="navlist_gray_arrow"></li> 
    <li class="navlist_gray">5. 评价</li> 
    <li class="navlist_gray_right"></li>   
  </ul>
</div>
<div id="content">
 <table width="100%" border="0" cellspacing="0" cellpadding="0" id="shopping">
  <tr>
    <td class="title_1"><input id="allCheckBox" type="checkbox" value=""  disabled/>选择</td>
    <td class="title_2" colspan="2">详细地址</td>
    <td class="title_3">联系电话</td>
    <td class="title_4">收货人</td>
    <td class="title_5">说明</td>
    <td class="title_7">操作</td>
  </tr>
  <tr>
    <td colspan="8" class="line"></td>
  </tr>
  <form action="saveOrder.let" method="post" id="form">
  <c:if test="${not empty addressList }">
  <c:forEach items="${addressList}" var="item" varStatus="s">
  <tr  class="product">
    <td class="cart_td_1">
    	<c:if test="${item.mallAddressDefault == 1 }">
    		<input class="ckBOX" name="mallAddressId" type="radio" value="${item.mallAddressId }" checked /><input type="hidden" name="uid" value="${item.mallAddressId }"></input>
    	</c:if>
    	<c:if test="${item.mallAddressDefault != 1 }">
    		<input class="ckBOX" name="mallAddressId" type="radio" value="${item.mallAddressId }" /><input type="hidden" name="uid" value="${item.mallAddressId }"></input>
    	</c:if>
    </td>
    <td class="cart_td_3" colspan="2" style="text-align:center"><a ></a>${item.mallAddressDetail}</td>
    <td class="cart_td_4">${item.mallAddressTel}</td>
    <td class="cart_td_5">${item.mallAddressName}</td>
    <td class="cart_td_7">${item.mallAddressInfo }</td>
    <td class="cart_td_8"><a href="usercenter/user4.jsp">编辑</a></td>
  </tr>	
  </c:forEach>
  </c:if>
  <c:if test="${empty addressList }">
  <h1>亲亲，还没有设置收货地址呢，快去设置一个吧</h1>
  </c:if>
  <tr>
  <td  colspan="3"><a href="usercenter/user4.jsp">添加新地址</a></td>
  <td colspan="10">
  	<input type="submit"  style="position:relative;left:260px" value="下一步"/>
  </td>
  </tr>
</form>
</table>
</div>
</body>
</html>
<script>
	var form = document.querySelector("#form");
	console.log(form);
	var cks = document.querySelectorAll(".ckBOX");
	console.log(cks);
	
	form.onsubmit = function () {
		var flag = false;
		var bl = false;
		var id = null;
		for(let i = 0; i < cks.length; i++){
			if(cks[i].checked){
				flag = true;
				id = cks[i].value;
				return;
			}
		}
		
		if(flag){
			bl = true;
		}else{
			sys.toastr.warn("请选中一条地址");
		}
		
		return bl;
	}
</script>